package com.zhuangyuan.cloud.data.model;

import javax.persistence.Entity;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by 10191042 on 2019-11-21.
 */

public class CateDetailModel {
    public static class CateChapterModel{
        private String imgUrl;
        private String description;
        private int index;

        public int getIndex() {
            return index;
        }

        public void setIndex(int index) {
            this.index = index;
        }

        public String getImgUrl() {
            return imgUrl;
        }

        public void setImgUrl(String imgUrl) {
            this.imgUrl = imgUrl;
        }

        public String getDescription() {
            return description;
        }

        public void setDescription(String description) {
            this.description = description;
        }

        @Override
        public int hashCode() {
            return this.imgUrl.toLowerCase().hashCode();
        }

        @Override
        public boolean equals(Object obj) {
            if(obj == null || !(obj instanceof CateChapterModel))
                return false;
            return this.hashCode() == obj.hashCode();
        }
    }

    private MenuModel menu;
    private List<CateChapterModel> cateList = new ArrayList<>();


    public MenuModel getMenu() {
        return menu;
    }

    public void setMenu(MenuModel menu) {
        this.menu = menu;
    }

    public List<CateChapterModel> getCateList() {
        return cateList;
    }

    public void addChapter(CateChapterModel chapter){
        if(!cateList.contains(chapter)){
            cateList.add(chapter);
        }
    }
}
